\hypertarget{class_symbol_table}{
\subsection{SymbolTable Class Reference}
\label{class_symbol_table}\index{SymbolTable@{SymbolTable}}
}
Symbol Table to hold \hyperlink{class_word}{Word} objects The Symbol table is used in different parts of the compiler.  


{\tt \#include $<$SymbolTable.h$>$}

\subsubsection*{Public Member Functions}
\begin{CompactItemize}
\item 
\hypertarget{class_symbol_table_1fbe6cec5594463b766db0ac58c9aa1d}{
\hyperlink{class_symbol_table_1fbe6cec5594463b766db0ac58c9aa1d}{SymbolTable} ()}
\label{class_symbol_table_1fbe6cec5594463b766db0ac58c9aa1d}

\begin{CompactList}\small\item\em Constructor. \item\end{CompactList}\item 
\hyperlink{class_word}{Word} $\ast$ \hyperlink{class_symbol_table_8c44b4851abd9055b9a6c20c0f0069a3}{find} (string word)
\begin{CompactList}\small\item\em Find a \hyperlink{class_word}{Word}. \item\end{CompactList}\item 
bool \hyperlink{class_symbol_table_36fd679760d1e4b0ad189958088decbb}{insert} (\hyperlink{class_word}{Word} $\ast$word)
\begin{CompactList}\small\item\em Insert a symbol (\hyperlink{class_word}{Word}). \item\end{CompactList}\item 
int \hyperlink{class_symbol_table_f3b25a335972a4a6bdb0394ca90f96c9}{search} (string word)
\begin{CompactList}\small\item\em Search all blocks (entire symbol table). \item\end{CompactList}\item 
bool \hyperlink{class_symbol_table_068f94e5b301b6760a839ac615fa8088}{isKeyword} (string word)
\begin{CompactList}\small\item\em Is the word a keyword. \item\end{CompactList}\item 
void \hyperlink{class_symbol_table_8725a7e0e7d8c6fdaa7cc9a67260c024}{insert} (const string $\ast$list)
\begin{CompactList}\small\item\em Insert a list words. \item\end{CompactList}\item 
bool \hyperlink{class_symbol_table_f6648e7bd96aad625b011d622333bf4f}{newBlock} ()
\begin{CompactList}\small\item\em Create a new block Pushes a new block (symbol table) on the stack. \item\end{CompactList}\item 
\hypertarget{class_symbol_table_e028189ea0f6b75312ed9c82b8d52939}{
void \hyperlink{class_symbol_table_e028189ea0f6b75312ed9c82b8d52939}{destroyBlock} ()}
\label{class_symbol_table_e028189ea0f6b75312ed9c82b8d52939}

\begin{CompactList}\small\item\em Remove a block Pops a block (symbol table) on the stack. \item\end{CompactList}\item 
int \hyperlink{class_symbol_table_c94f9bee89468bc33e4996e6e9631f85}{blockLevel} ()
\begin{CompactList}\small\item\em Level of current block. \item\end{CompactList}\item 
int \hyperlink{class_symbol_table_30f1e6d28353006840f71fe1ae87f373}{nextOffset} ()
\begin{CompactList}\small\item\em Next offset. \item\end{CompactList}\item 
void \hyperlink{class_symbol_table_37c017f8df645a682a8acd3d7e05d4f5}{dumpTable} ()
\begin{CompactList}\small\item\em Dump the table for debugging purposes. \item\end{CompactList}\end{CompactItemize}


\subsubsection{Detailed Description}
Symbol Table to hold \hyperlink{class_word}{Word} objects The Symbol table is used in different parts of the compiler. 

It will give linear access time for finding a Symbol. 

\subsubsection{Member Function Documentation}
\hypertarget{class_symbol_table_8c44b4851abd9055b9a6c20c0f0069a3}{
\index{SymbolTable@{SymbolTable}!find@{find}}
\index{find@{find}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}{\bf Word} $\ast$ SymbolTable::find (string {\em word})}\hfill}
\label{class_symbol_table_8c44b4851abd9055b9a6c20c0f0069a3}


Find a \hyperlink{class_word}{Word}. 

Currently, not implemented. \hyperlink{class_scanner}{Scanner} (assignmnet 1) does not need it. The definition may change later on. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em word}]the string we are trying to find \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The found symbol (\hyperlink{class_word}{Word}) \end{Desc}
\hypertarget{class_symbol_table_36fd679760d1e4b0ad189958088decbb}{
\index{SymbolTable@{SymbolTable}!insert@{insert}}
\index{insert@{insert}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}bool SymbolTable::insert ({\bf Word} $\ast$ {\em word})}\hfill}
\label{class_symbol_table_36fd679760d1e4b0ad189958088decbb}


Insert a symbol (\hyperlink{class_word}{Word}). 

The \hyperlink{class_word}{Word} will only be inserted if it is not in the table already. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em word}]The \hyperlink{class_word}{Word} object to be inserted \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The \hyperlink{class_word}{Word} inserted or the previously inserted word \end{Desc}
\hypertarget{class_symbol_table_f3b25a335972a4a6bdb0394ca90f96c9}{
\index{SymbolTable@{SymbolTable}!search@{search}}
\index{search@{search}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}int SymbolTable::search (string {\em word})}\hfill}
\label{class_symbol_table_f3b25a335972a4a6bdb0394ca90f96c9}


Search all blocks (entire symbol table). 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em word}]The string to search for \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]an iterator of block the \hyperlink{class_word}{Word} was found in \end{Desc}
\hypertarget{class_symbol_table_068f94e5b301b6760a839ac615fa8088}{
\index{SymbolTable@{SymbolTable}!isKeyword@{isKeyword}}
\index{isKeyword@{isKeyword}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}bool SymbolTable::isKeyword (string {\em word})}\hfill}
\label{class_symbol_table_068f94e5b301b6760a839ac615fa8088}


Is the word a keyword. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em word}]The string to see if it is a keyword \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]True or False \end{Desc}
\hypertarget{class_symbol_table_8725a7e0e7d8c6fdaa7cc9a67260c024}{
\index{SymbolTable@{SymbolTable}!insert@{insert}}
\index{insert@{insert}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}void SymbolTable::insert (const string $\ast$ {\em list})}\hfill}
\label{class_symbol_table_8725a7e0e7d8c6fdaa7cc9a67260c024}


Insert a list words. 

Create a \hyperlink{class_word}{Word} from a string array and insert them. This is primarily used to insert the list of keywords. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em list}]an array of strings \end{description}
\end{Desc}
\hypertarget{class_symbol_table_f6648e7bd96aad625b011d622333bf4f}{
\index{SymbolTable@{SymbolTable}!newBlock@{newBlock}}
\index{newBlock@{newBlock}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}bool SymbolTable::newBlock ()}\hfill}
\label{class_symbol_table_f6648e7bd96aad625b011d622333bf4f}


Create a new block Pushes a new block (symbol table) on the stack. 

Also inserts the Keywords into new block. \hypertarget{class_symbol_table_c94f9bee89468bc33e4996e6e9631f85}{
\index{SymbolTable@{SymbolTable}!blockLevel@{blockLevel}}
\index{blockLevel@{blockLevel}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}int SymbolTable::blockLevel ()}\hfill}
\label{class_symbol_table_c94f9bee89468bc33e4996e6e9631f85}


Level of current block. 

\begin{Desc}
\item[Returns:]The Level of the current block \end{Desc}
\hypertarget{class_symbol_table_30f1e6d28353006840f71fe1ae87f373}{
\index{SymbolTable@{SymbolTable}!nextOffset@{nextOffset}}
\index{nextOffset@{nextOffset}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}int SymbolTable::nextOffset ()}\hfill}
\label{class_symbol_table_30f1e6d28353006840f71fe1ae87f373}


Next offset. 

Get the next offset in the current block \begin{Desc}
\item[Returns:]The offset \end{Desc}
\hypertarget{class_symbol_table_37c017f8df645a682a8acd3d7e05d4f5}{
\index{SymbolTable@{SymbolTable}!dumpTable@{dumpTable}}
\index{dumpTable@{dumpTable}!SymbolTable@{SymbolTable}}
\paragraph{\setlength{\rightskip}{0pt plus 5cm}void SymbolTable::dumpTable ()}\hfill}
\label{class_symbol_table_37c017f8df645a682a8acd3d7e05d4f5}


Dump the table for debugging purposes. 

Will print a formated listing of the symbol table. 